<template>
  <view class="order-update">
    <view class="order_gift_view">
		<view v-for="(item, productListIndex) in productList" :key="productListIndex">
			<view class="pictrue">
				<image :src="item.image"/></image>
			</view>
			<view class="order_form2">
				<view class="title">{{item.storeName }}</view>
				
				<view class="inputLine">
					<view class="text">数量：</view>
					<view class="text_input2"><input type="text" v-model="item.totalnum"/></view>
				</view>
				
			</view>
			
			<view class="gify_add_btn" @click="addGift(item)">+</view>
		</view>
		
		<view class="order_form_bottom_line"></view>
		
		<view class="order_total_collect">
			<br/>
			<view class="inputLine2">
				<view class="text">赠品明细</view>
			</view>
			<view class="inputLine2" v-for="(item, giftListIndex) in giftList" :key="giftListIndex">
				<view class="text">{{item.storeName }}</view>
				<view class="text2">{{item.totalnum }}</view>
			</view>
			
			
		</view>
		<view class="order_add_btn2" @click="giftSubmit()">确定</view>
	</view>
	
	
  </view>
</template>

<script>

  import { getProducts} from '@/api/store'
  
    export default {
  	name: 'GoodsList',
      components: {
      
      },
      data: function () {
        return {
          id:'',
		  price:'',
			productList: [],
			giftList: [],
			where: {
			  page: 1,
			  limit: 8,
			  news: 0,
			  priceOrder: '',
			  salesOrder: '',
			  isGift:1,
			},
        }
      },
      computed: {
        
      },
      mounted: function () {
        this.id = this.$yroute.query.id;
		this.price = this.$yroute.query.price;
  	    this.getProductList();
      },
      methods: {
        getProductList() {
          var that = this
          var q = that.where
          getProducts(that.where).then(res => {
        	  console.log(res.data);
			  that.productList=res.data;
         
          })
        },
		addGift(item){
			var that=this
			that.giftList.push(item)
		},
		giftSubmit(){
			var that=this
			uni.setStorageSync('giftList', that.giftList)
			console.log(uni.getStorageSync('giftList'))
			
			this.$yrouter.push({
			  path: "/pages/agent/Order/OrderUpdate/index",
			  query: {
			    id: that.id,
				price:that.price
			  },
			});
		}
      
      },
    };
</script>

<style scoped lang="less">
  
</style>
